<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class ApiController extends Controller
{
    //
    public function json($data, int $code = 200)
    {
        return response()->json($data, $code);
    }
    public function success(string $message, array $data = [], int $code = 200)
    {
        return response()->json(
            [
                'message' => $message,
                'data' => $data
            ],
            $code
        );
    }
    public function error(String $error, array $data = [], int $code = 404)
    {
        return response()->json(
            [
                'message' => $error,
                'data' => $data,
                'code' => $code
            ]
        );
    }
}
